package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.web.bind.annotation.Mapping;

import java.util.List;

@Mapper
public interface SetmealMapper {
    //新增Setmeal
//    @Insert("insert into setmeal(category_id, name, price, status, description, image, create_time, update_time, create_user, update_user) VALUES " +
//            "(#{categoryId},#{name},#{price},#{status},#{description},#{image},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    Long addSetmeal(Setmeal setmeal);

    @Select("select id from setmeal where name=#{name}")
    Long getSetmealId(String name);

    Page<SetmealVO> pageQuery(SetmealPageQueryDTO setmealPageQueryDTO);

    @Update("update setmeal set status=#{status} where id=#{id}")
    void setStatus(Integer status, Long id);

    @Select("select * from setmeal where id=#{id}")
    Setmeal getSetmealById(Long id);

    @Update("update setmeal set category_id=#{categoryId},name=#{name},price=#{price},description=#{description},image=#{image},create_time=#{createTime},update_time=#{updateTime},create_user=#{createUser},update_user=#{updateUser} where id=#{id}")
    void updateSetmealInfo(Setmeal setmeal);



    void removeSetmealByIds(List<Long> ids);

    @Select("select * from setmeal where category_id=#{categoryId}")
    List<Setmeal> list(Integer categoryId);

    @Select("select count(*) from setmeal  where status=1")
    Integer getSold();
    @Select("select count(*) from setmeal  where status=0")
    Integer getDisContinuedSold();
}
